<template>
	<view class="all">
		<view class="part" style="width: 100%; height: 100%; margin-bottom: 10rpx;" v-for="(item,index) in demoList"
			:key="index">
			<view
				style="margin: 0 auto; font-size: 30rpx; color: white;display: flex; justify-content: center; align-items: center; background-color: rgb(1, 152, 213); width: 90%; height: 50rpx; border-radius: 10rpx;">
				{{item.name}}
			</view>
			<view class="demoList"
				style="width: 100%; height: 100%; display: flex; flex-wrap: wrap; justify-content: space-between;">
				<view
					style="height: 500rpx; width: 45%; margin:15rpx;border-bottom-left-radius: 10rpx; border-bottom-right-radius: 10rpx;"
					v-for="(item2,index) in item.demoFactoryList" :key="index" :data-item="item2"
					@click="openDemoVideo">
					<img style="height: 450rpx; width: 100%; display: block; background-size: contain;"
						:src="item2.imgUrl" alt="" />
					<view
						style="background-color: rgb(1, 152, 213); border-bottom-left-radius: 10rpx; border-bottom-right-radius: 10rpx; color: white; width: 100%; height: 50rpx; line-height: 50rpx; font-size: 35rpx; text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;">
						{{ item2.name }}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import Http from "@/utils/http"
	const http = new Http()
	const app = getApp()
	export default {
		data() {
			return {
				demoList: []
			}
		},
		onLoad() {
			this.getList();
		},
		methods: {
			openDemoVideo(e) {
				console.log("执行了===>", e);
				console.log(e.currentTarget.dataset.item.id);
				uni.navigateTo({
					url: '/subpkg/demoFactory/demoVideo?id=' + e.currentTarget.dataset.item.id
				})
			},
			getList() {
				http.get('v1/system/category/list').then(res => {
					if (res.data.msg == "" || res.data.msg == null) {
						uni.showToast({
							title: '暂无数据',
							icon: 'none'
						})
					} else {
						this.demoList = res.data.data;
					}
				})
			}
		}
	}
</script>

<style>
	.all {
		min-height: 100vh;
		height: 100%;
		background-size: contain;
		background-image: url('https://jz-cnsiot.oss-cn-shanghai.aliyuncs.com/mojian/2024/3/21/1711006123961ed7aa87f84224969b18a90325edf048b.png');
		background-repeat: no-repeat;
		padding: 10rpx;
	}
</style>